﻿using System;
using System.Collections.Generic;
using SMLib.Interoperability.DOT;
using MBT.Modeling;

namespace MBT.TestStateLevel
{
	/// <summary>
	/// Dot helper for test automaton.
	/// </summary>
	/// <exception cref='NotImplementedException'>
	/// Is thrown when a requested operation is not implemented for a given type.
	/// </exception>
    public class DotHelper_TA : DotHelper<TA_State,TA_State.TA_Transition>
    {
        public static void WriteToDot(string path, TestAutomaton dfa)
        {
            string DotString = "Digraph StateSpace{\r\n";
            foreach (TA_State st in dfa.GetStates())
            {
                foreach (TA_State.TA_Transition tr in st.Transitions)
                {
                    DotString += st.id + " -> " +
                        tr.Destination.id + "[label=\""
                        + (tr.isControllable ? "?" : "!") +
                        tr.ToString()
                        + "\"];\r\n";
                }
            }
            DotString += "}";
            System.IO.File.WriteAllText(path, DotString);
        }

        /// <summary>
        /// Read a DFA from file.
        /// <remarks>Each line of the file should have the following pattern: "src" -&gt; "dst" : "label"</remarks>
        /// </summary>
        /// <param name="inputFile">full path of input file</param>
        public static TestAutomaton ReadFromDOT(string inputFile)
        {
            throw new NotImplementedException();
        }
    }
}
